package com.kgc.service.impl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.kgc.api.user.UserInfoApi;
import com.kgc.bean.User;
import com.kgc.bean.UserVO;
import com.kgc.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * Create on 2021/6/21
 * <p>
 * Author YANQINGCHAO
 * <p>
 * Description:
 */
@Service
@Slf4j
public class UserServiceImpl implements UserService {

    @Reference(timeout = 30000)
    private UserInfoApi userInfoApi;

    @Override
    public UserVO queryUserById(Integer userId) {
        User user = userInfoApi.queryUserById(userId);
        UserVO userVO = new UserVO();

        BeanUtils.copyProperties(user,userVO);
        if(user.getIsvip()==0){
            userVO.setIsvip("不是");
        }else{
            userVO.setIsvip("是");
        }
        return userVO;
    }

    @Override
    public Integer signIn(Date date, Integer userId) {
        return userInfoApi.checkIn(date,userId);
    }
    @Override
    public Boolean renewingMember(String token) {
        return userInfoApi.renewingMember(token);
    }
    @Override
    public Integer collectResolve(String goodsId, Integer userId) {
        Integer result=userInfoApi.collectResolve(goodsId,userId);
        log.info("收藏处理结果：{}",result);
        return result;
    }
}
